<style type="text/css">
#cas
{
    background: #fbfbfb;
    border: thin solid rgb(0,0,0);
    padding-left: 1%;
}
</style>
<div id="cas"> 
<?php
    include("config.php");
    $desc = explode("[.d.]",base64_decode($param));
    if (sizeof($desc) == 2)
    {
        $param = explode("[.e.]",$desc[1]);
        $desc = $desc[0];
    }
    elseif (sizeof($desc == 1))
    {
        $param  = explode("[.e.]",$desc[0]);
        $desc = "";
    }
    $descriptorspec = array(
        0 => array("pipe", "r"),
        1 => array("pipe", "w"),
        2 => array("file", $DOCUMENT_ROOT."/error-scilab-output.txt", "a")
    );

    $env = array('HOME' => $DOCUMENT_ROOT,'DISPLAY' => '0', 'LD_ASSUME_KERNEL' => '2.4.1');

    $process = proc_open('/usr/local/maple/bin/maple', $descriptorspec, $pipes, $cwd, $env);
    if (is_resource($process)) {
        $str1 = array("%","'");
        $str2 = array("\%","''");
        for ($i=0; $i<count($param);$i++)
            fwrite($pipes[0],$param[$i]."\n");
        fclose($pipes[0]);
        echo "<pre>\n";	
        echo stream_get_contents($pipes[1]);
        echo "\n</pre>\n";
        fclose($pipes[1]);
        $return_value = proc_close($process);
    }
?>
</div>
<?php
    if (!empty($desc))
    {
?>
        <p><strong><?php echo Descricao ?>:</strong> <?php echo $desc ?></p>
<?php
    }
?>
